# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.views.generic import ListView, DetailView, CreateView, DeleteView, UpdateView
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse, Http404
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.decorators import login_required
from django_filters.views import FilterView
from django.urls import reverse, reverse_lazy
from datetime import datetime
import json
from .models import Tasks
from .forms import TasksCreateForm, TasksUpdateForm
# Create your views here.


class TasksListView(LoginRequiredMixin, ListView):
    model = Tasks
    login_url = "/v1/login/"
    template_name = 'datapanel/tasks_list.html'
    context_object_name = 'tasks'
    paginate_by = 10


class TasksCreateView(CreateView):
    model = Tasks
    form_class = TasksCreateForm
    template_name = 'datapanel/tasks_form.html'
    success_url = reverse_lazy('datapanel:tasks_list')


class TasksUpdateView(UpdateView):
    model = Tasks
    template_name = 'datapanel/tasks_form.html'
    form_class = TasksUpdateForm
    success_url = reverse_lazy('datapanel:tasks_list')


class TasksDeleteView(DeleteView):
    model = Tasks
    success_url = reverse_lazy('datapanel:tasks_list')
    context_object_name = 'tasks'
    template_name = 'datapanel/tasks_delete.html'
